﻿namespace Jsl.StyleCop.CSharp.RefactoringRules
{
    using Microsoft.VisualStudio.TestTools.UnitTesting;

    [TestClass]
    public class TestDontCompareToBooleanConstant : TestBase<RuleAnalyzer>
    {
        #region Constructors
        /// <summary>
        /// Initializes a new instance of the <see cref="TestDontCompareToBooleanConstant"/> class.
        /// </summary>
        public TestDontCompareToBooleanConstant()
            : base(RuleAnalyzer.DontCompareToBooleanConstant)
        {
        }
        #endregion Constructors

        [TestMethod]
        public void Comparing_boolean_to_false_is_bad()
        {
            this.TestMethod(
@"public bool Method(bool parameter)
{
    return parameter == false;
}",
                new ViolationInfo(3, "Don't compare a boolean to boolean constants."));
        }

        [TestMethod]
        public void Comparing_boolean_to_true_is_bad()
        {
            this.TestMethod(
@"public bool Method(bool parameter)
{
    return parameter == true;
}",
                new ViolationInfo(3, "Don't compare a boolean to boolean constants."));
        }

        [TestMethod]
        public void Comparing_false_to_boolean_is_bad()
        {
            this.TestMethod(
@"public bool Method(bool parameter)
{
    return false == parameter;
}",
                new ViolationInfo(3, "Don't compare a boolean to boolean constants."));
        }

        [TestMethod]
        public void Comparing_true_to_boolean_is_bad()
        {
            this.TestMethod(
@"public bool Method(bool parameter)
{
    return true == parameter;
}",
                new ViolationInfo(3, "Don't compare a boolean to boolean constants."));
        }
    }
}